<template>
  <dv-border-box-7 id="third-left-two-chart">
    <!-- <div class="third-right-tittle">生产统计</div> -->
    <div id="thirdLeftTwoChart"></div>
  </dv-border-box-7>
</template>

<script>
import * as echarts from "echarts";
import Axios from "axios";
export default {
  name: "thirdLeftTwoChart",

  data() {
    return {
      ProductionData: {
        X: [500, 600, 450, 900,300],
        // y:[1.3,1.5,1.7,1.1,0.6,0.7,0.8]
      },
    };
  },
  methods: {
     UpdateData() {
      var _this = this;
      var chartDom = document.getElementById("thirdLeftTwoChart");
      var myChart = echarts.init(chartDom);
      var option;
        var url = this.$baseUrl + "statistics/one-month-product";
       Axios.get(url).then((response) => (_this.ProductionData.X = Object.values(response.data)));

      option = {
        title: {
          text: "月生产统计",
          textStyle: {
            color: "white",
          },
          left: "center",
        },
        tooltip: {},
        legend: {
          top: "10%",
          textStyle: {
            color: "white",
          },
        },
        xAxis: {
          type: "value",
          name: "数量",
          nameTextStyle:{
            color:'white',
          },
          axisLabel: {
            formatter: "{value}",
            textStyle: {
              color: "white",
            },
          },
        },
        yAxis: {
          type: "category",
          data: ["型号一", "型号二", "型号三", "型号四"," 型号五"],
          axisLabel: {
            textStyle: {
              color: "white",
            },
          },
        },
        series: [
          {
            name: "数量(个)",
            data: this.ProductionData.X,
            type: "bar",
            itemStyle:{
              color:"#34d5aa"
            },


            tooltip: {
              valueFormatter: function (value) {
                return value;
              },
            },
          },
        ],
      };
      option && myChart.setOption(option);
      	setTimeout(() => {
					this.UpdateData()
				}, 1000);
    },
  },
  mounted() {
    this.UpdateData();
  },
};
</script>

<style lang="less">
#third-left-two-chart {
  width: 25%;
  height: 100%;
  background-color: rgba(6, 30, 93, 0.5);
  border-top: 2px solid rgba(1, 153, 209, 0.5);
  box-sizing: border-box;
  margin: 10px;
  float: left;
  // .third-right-tittle{
  //   font-size: 20px;
  //   display: flex;
  //   justify-content: center;
  //   align-items: center;
  // }
  #thirdLeftTwoChart {
    width: 100%;
    height: 100%;
  }
}
</style>

